    //
//  AttendSearchFormController.m
//  BVCMS
//
//  Created by Allen Thomas on 11/8/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "AttendSearchFormViewController.h"
#import "AttendSearchResultsViewController.h"
#import "AddNewPersonViewController.h"

@implementation AttendSearchFormViewController

-(void) viewDidLoad {
	[super viewDidLoad];
	self.title = @"Individual Search";
	returnKeyType = UIReturnKeyDone;
}

-(void) search_callback:(NSData *)data {
	NSString *output = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
	NSLog(@"%@", output);
	
	[self parseXml:data];
	
	// Stop activity indicator
	[self.view sendSubviewToBack:loadingView];
	[searchButton setEnabled:YES];
	[clearButton setEnabled:YES];
	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
	
	AttendSearchResultsViewController *searchResults = [[AttendSearchResultsViewController alloc]
													  initWithNibName:@"AttendSearchResultsView" bundle:[NSBundle mainBundle]];
	searchResults.title = @"Results";
	searchResults.resultsData = self.people;
	searchResults.numberOfResults = self.numberOfResults;
	if([nameField.text length] > 0 ) {
		searchResults.fullname = [nameField text];
	}
	NSLog(@"loading results");
	[self.navigationController pushViewController:searchResults animated:YES];
	[searchResults release];
	
	[output release];
}

/*
 This action is performed when the user clicks the done button on the keyboard.
 */
-(IBAction)textFieldDone:(id)sender {
	[sender resignFirstResponder];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
